1. Field of the Invention
The present invention relates to an audio player having an electronic shock protection (ESP) function, and more particularly, to an audio encoding method and apparatus by which when encoding audio data read from a compact disc (CD) is performed before storing the data, if a shock occurs, a point for linking valid audio data in a buffer can be accurately found and encoding is performed irrespective of whether the encoding rate of the audio data is a constant bit rate or a variable bit rate.
2. Description of Related Art
Recording media such as a CD and a DVD are widely used to store audio files because of their relatively low prices and large capacities. By using one audio player, a user reproduces an audio file, such as an MP3, WMA, or AAC file, encoded and recorded on a CD. In particular, in the case of a portable audio player or a car CD player, a protection against external shock should be provided for seamless reproduction. For this, usually a mechanical buffer or an external electronic shock protection (ESP) chipset is used. The ESP function is to output clean sound even when there is an external shock, and not to remove noise caused by a scratched or contaminated CD.
A conventional ESP function will now be explained with reference to FIGS. 1A through 1F. As shown in FIG. 1A, if an external shock occurs in a fifth frame, a servo becomes unstable and noise occurs continuously in the fifth, sixth, and seventh frames. As shown in FIG. 1B, until the servo becomes stable, audio data of frames in which noise occurs is stored in a buffer. As shown in FIG. 1C, a pattern unique to a frame in the fourth frame is selected and data after the unique pattern is discarded. As shown in FIG. 1D, the CD is rewound to the start point of the fourth frame and then audio data is read from the fourth frame, and the unique pattern to the fourth frame is found. As shown in FIG. 1E, immediately after the location where the unique pattern of the fourth frame is in the buffer, new audio data beginning from the fifth frame is linked and stored. As a result, as shown in FIG. 1F, noiseless audio data is stored in the buffer and even when a shock occurs, seamless clean sound can be output.
If the conventional ESP function as described above is set in an audio player, in a normal mode in which a shock does not occur, an audio output is generated directly from data read from a CD and provided to the user, and in an abnormal mode in which a shock occurs, an audio output is generated from data provided from the buffer and provided to the user. However, this conventional ESP function cannot perform its function when an external shock lasts for a long while exceeding a shock protection time. In order to extend a shock protection time, audio data read from a CD is encoded before stored. In this case, the shock protection time can vary depending on the size of a buffer and the encoding rate of data.
At present, when audio encoding suggested by MPEG-1 and MPEG-2 is performed, if a constant bit rate is employed, sync information is placed at the start part of each frame, and in case of MPEG-4, if the constant bit rate is not used, frame length information is placed at the start part of each frame. Accordingly, when a shock occurs and valid data is desired to be linked in the buffer, if the encoding rate is a constant bit rate, the length of each frame, that is, an occupying area in the buffer, is constant such that an area storing a frame before the frame in which a shock occurs can be easily found. However, if the encoding rate is a variable bit rate, the length of each frame, that is, the size of an occupying area in the buffer, is different to each other such that an area storing a frame before the frame in which a shock occurs cannot be found only with the frame length information recorded in the start part of each frame in the buffer